<?php
require_once('Extension/View/Helper/Abstract.php');

require_once('Extension/Locale/Format.php');

class Extension_View_Helper_N extends Extension_View_Helper_Abstract
{
    public function N($numberString, $precision = 2, $type = 'F') {
        $options = array(
            'precision' => $precision, 
            'locale' => Kbs::initLocale(),
            'number_format' => '#0.00',
        );

        if ($type == 'F') {
            $tempNumber = Extension_Locale_Format::getFloat($numberString, $options);
            $number = Extension_Locale_Format::toFloat($tempNumber, $options);
        } else {
            $tempNumber = Extension_Locale_Format::getNumber($numberString, $options);
            $number = Extension_Locale_Format::toNumber($tempNumber, $options);
        }

        return $number;
    }
}